package com.andnnl.event;

import com.andnnl.event.events.ClickEvent;
import com.andnnl.event.events.DblClickEvent;
import com.andnnl.event.events.Event;
import com.andnnl.event.listener.ClickEventHandler;
import com.andnnl.event.listener.DbClickEventHandler;
import com.andnnl.event.source.Button;

/**
 * Created by chenss on 2021/5/11.
 */
public class EventTest {
    private Event currentEvent;

    private Button button;

    public static void main(String[] args) {
        EventTest test = new EventTest();
        test.initComponent();
        test.testCommonEvents();
    }

    public void initComponent() {

        button = new Button();

        button.addEventListener((ClickEventHandler) event -> System.out.println("Button was clicked!"));

        button.addEventListener((DbClickEventHandler) event -> System.out.println("Button was double clicked!"));

    }
    public void testCommonEvents() {
        currentEvent = new ClickEvent();
        button.notifyListeners(currentEvent);

        currentEvent = new DblClickEvent();
        button.notifyListeners(currentEvent);
    }

}
